/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package at.tugraz.hidipic.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author mario
 */
@Entity
@Table(name = "dataitem", uniqueConstraints =
@UniqueConstraint(columnNames = {"name", "url"}))
@Inheritance(strategy = InheritanceType.JOINED)
public class DataItem implements Serializable {

    @Id
    private String name;
    private String title;
    private String url;
    private String type;
    @ManyToOne
    @JoinColumn(name = "idUser")
    private User creator;
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public User getCreator() {
        return creator;
    }

    public void setCreator(User creator) {
        this.creator = creator;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof DataItem) {
            return this.name.equals(((DataItem) obj).getName());
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return this.name.hashCode();
    }
}
